use std::str::FromStr;

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum COBDirection {
    Left,
    Right,
    Down,
    Up,
}

impl FromStr for COBDirection {
    type Err = String;
    fn from_str(s: &str) -> Result<Self, Self::Err> {
        match s {
            "left" => Ok(COBDirection::Left),
            "right" => Ok(COBDirection::Right),
            "up" => Ok(COBDirection::Up),
            "down" => Ok(COBDirection::Down),
            _ => Err(format!("Unkonw direction literal '{}'", s).into())
        }
    }
}